package com.ecsolutions.service.liability;

import com.ecsolutions.dao.liability.LiabilityDao;
import com.ecsolutions.entity.liability.LiabilityEntity;
import com.ecsolutions.entity.liability.LoanTypeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/5/15.
 */
@Service
public class LiabilityServiceImpl implements LiabilityService {
    private LiabilityDao liabilityDao;

    @Autowired
    public LiabilityServiceImpl(LiabilityDao liabilityDao) {
        this.liabilityDao = liabilityDao;
    }

    @Override
    public List<LiabilityEntity> getLiabilityList(String customer_code) {
        List<LiabilityEntity> liabilityEntities = this.liabilityDao.getCurrencies(customer_code);
        String currency = null;
        for (LiabilityEntity liabilityEntity:liabilityEntities
             ) {
            currency = liabilityEntity.getBalance_currency();
            List<LoanTypeEntity> loanTypeEntities = this.liabilityDao.getLoanTypes(customer_code, currency);
            liabilityEntity.setLoanType(loanTypeEntities);
        }
        return liabilityEntities;
    }
}
